package bma.common.netty.protobuf.core;

import java.util.concurrent.Executor;

import bma.common.langutil.concurrent.TimerManager;
import bma.common.langutil.core.ExceptionUtil;
import bma.common.langutil.core.SizeUtil;
import bma.common.langutil.core.SizeUtil.Unit;

public class NettyProtobufConfig {

	protected int maxLength = 1024 * 1024;
	protected int protocolVersion = 1;	
	protected Executor executor;
	protected TimerManager timer;

	public int getMaxLength() {
		return maxLength;
	}

	public void setMaxLength(int maxLength) {
		this.maxLength = maxLength;
	}
	
	public void setFrameSize(String sz) {
		try {
			this.maxLength = (int) SizeUtil.convert(sz, 1024, Unit.B);
		} catch (Exception e) {
			throw ExceptionUtil.throwRuntime(e);
		}
	}

	public int getProtocolVersion() {
		return protocolVersion;
	}

	public void setProtocolVersion(int protocolVersion) {
		this.protocolVersion = protocolVersion;
	}	
	
	public Executor getExecutor() {
		return executor;
	}

	public void setExecutor(Executor exector) {
		this.executor = exector;
	}

	public TimerManager getTimer() {
		return timer;
	}

	public void setTimer(TimerManager timer) {
		this.timer = timer;
	}

}
